﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Snowdreamist.Windows.Document.Adapter
{
    [Flags]
    public enum AcceptType
    {
        None = 0,
        String = 1,
        Inline = 2,
        Block = 4,
        UIElement = 8
    }
    /// <summary>
    /// Element adapter
    /// </summary>
    public interface IElementAdapter
    {
        /// <summary>
        /// The target type of this adapter
        /// Note:
        ///     Why don't use Type here?
        ///     Type is a strong identity solution that it may drive into trouble when it requires weak identity or identity re-mapping
        ///     e.g.
        ///     <![CDATA[
        ///         compose these ubb code:
        ///         [size=0]<metadata identity="ImageWall">blablablablabla</metadata>[/size=0]
        ///         [img]a image uri[/img]
        ///         the <metadata> in [size] contains the meta info of the following label "img", which means this img should be shown in "ImageWall",
        ///         but image wall is not a strong-type identity, it can map to any element adapted from it.
        ///         So, even we can get the document element maps to "img", but actually in this situation, it should re-map to "ImageWall"
        ///     ]]>
        /// </summary>
        string TargetElementIdentity { get; }
        /// <summary>
        /// Accept child type
        /// </summary>
        AcceptType AcceptChildType { get; }
        /// <summary>
        /// Convert
        /// </summary>
        /// <param name="source">source</param>
        /// <param name="metadata">source metadata</param>
        /// <returns></returns>
        object Convert(object source, ContentMetadata metadata);
        /// <summary>
        /// Append child
        /// </summary>
        /// <param name="child"></param>
        void Append(object element, object child);
        /// <summary>
        /// Append range
        /// </summary>
        /// <param name="children"></param>
        void AppendRange(object element, IEnumerable<object> children);
    }
}
